#include "StdAfx.h"
#include "PortLan.h"

CPortLan::CPortLan(void):protocol(EProtocolUnknown),timeout(INFINITE){
}

CPortLan::~CPortLan(void){
	DelObj(m_io);
}

bool CPortLan::SetIOs(CXMLElement *pItem){
	LPTSTR pName = pItem->GetElementName();
	LPTSTR pValue = pItem->GetValue();
	if(0 != strcmp(pName, "IOs")){
		return false;
	}
	src_ip = pItem->GetFirstChild()->GetValue();
	src_port = pItem->GetNextChild()->GetValue();//="1666" 
	des_ip = pItem->GetNextChild()->GetValue();//"127.0.0.1" 
	des_port = pItem->GetNextChild()->GetValue();//="1667" 
	timeout = atoi(pItem->GetNextChild()->GetValue());//="300"
	pValue = pItem->GetNextChild()->GetValue();
	if(0 == strcmp(pValue, "TCP")){
		protocol = EProtocolLanTcp;
	}
	else if(0 == strcmp(pValue, "UDP")){
		protocol = EProtocolLanUdp;
	}
	else{
		protocol = EProtocolUnknown;
	}

	//
	while(pItem->GetNextChild()){
		m_io.push_back(new CIoInfor(pItem->GetCurrentChild()));
	}
	return true;
}